package com.xzmzhp.dao.activity;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xzmzhp.dao.activity.SQL.ActivitySql;
import com.xzmzhp.pojo.activity.Activity;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author: 王源(xm)
 * @create: 2022-03-27 19:54
 * @program: ams
 * @description: 活动管理数据库交互类
 */
@Repository
public interface ActivityMapper extends BaseMapper<Activity> {

    /**
     * 查询活动全部数据
     * @return 活动信息
     */
    @Select("select activity_id,activity_name,activity_date,activity.society_id,society_name " +
            "from activity,society where activity.society_id = society.society_id order by activity_date")
    List<Activity> findAll();

    /**
     * 根据相应的参数查询数据
     * @param param 参数
     *        societyId 社团id
     *        activityName 活动名称
     *        startTime 开始时间
     *        endTime  结束时间
     * @return 活动信息
     */
    @SelectProvider(type = ActivitySql.class,method = "findByParam")
    List<Activity> findByParam(Map<String,Object> param);

    /**
     * 获取最新的活动信息
     * @return 活动信息
     */
    @Select("select activity_id,activity_name,activity_date FROM activity ORDER BY id DESC LIMIT 0,1")
    Activity findLatestActivities();
}
